#include <Thunk/ThisToCdecl.h>
//#include <assert.h>

#define THUNK_MACHINE_CODE_IMPLEMENT
#include <Thunk/MachineCodeMacro.h>

namespace Thunk
{
	ThisToCdecl::~ThisToCdecl()
	{}

	ThisToCdecl::ThisToCdecl(const void *Obj,int memFunc)
		__THIS_TO__CDECL_CODES()
	{
		Helper::SetTransferDST(&CALL,memFunc);
	}

	dword_ptr ThisToCdecl::Attach(dword_ptr newObj)
	{
		dword_ptr oldObj = m_this;
		m_this = newObj;
		return oldObj;
	}

	dword ThisToCdecl::Attach(dword newFunc)
	{
		dword oldFunc = Helper::GetTransferDST(&CALL);
		Helper::SetTransferDST(&CALL,newFunc);
		return oldFunc;
	}
}
